package com.droidnow.droidaudio;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import com.droidnow.adapter.SuiteAdapter;
import com.droidnow.common.Request;
import com.droidnow.model.Rss;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * User: tinnd
 * Date: 4/18/13
 * Time: 11:48 AM
 * To change this template use File | Settings | File Templates.
 */
public class SuiteListActivity extends Activity {
	ListView list;
	SuiteAdapter adapter;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.suitelist);
		this.initialize();
	}

	private void initialize() {
		final ArrayList<HashMap<String, String>> bookList = Rss.GetBooksList();
		list = (ListView) findViewById(R.id.lstSuitelist);

		// Getting adapter by passing xml data ArrayList
		adapter = new SuiteAdapter(this, bookList);
		list.setAdapter(adapter);


		// Click event for single list row
		list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				HashMap<String, String> doc;
				doc = bookList.get(position);
				String itemId = doc.get(Rss.KEY_ID);

				Log.e("DROID----------SUITE click", "Item " + itemId);
				Intent intent = new Intent(SuiteListActivity.this, PlayListActivity.class);
				intent.putExtra(Request.INTENT_PLAY_TYPE, Request.PLAY_BOOK);
				intent.putExtra(Request.INTENT_PLAY_ID, itemId);
				startActivity(intent);
			}
		});
	}
}